/*********************************************************
 *********************************************************
 ********************                  *******************
 *************                                ************
 *******                  _oo0oo_                  *******
 ***                     o8888888o                     ***
 *                       88" . "88                       *
 *                       (| -_- |)                       *
 *                       0\  =  /0                       *
 *                     ___/`---'\___                     *
 *                   .' \\|     |// '.                   *
 *                  / \\|||  :  |||// \                  *
 *                 / _||||| -:- |||||- \                 *
 *                |   | \\\  -  /// |   |                *
 *                | \_|  ''\---/''  |_/ |                *
 *                \  .-\__  '-'  ___/-. /                *
 *              ___'. .'  /--.--\  `. .'___              *
 *           ."" '<  `.___\_<|>_/___.' >' "".            *
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |          *
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /          *
 *      =====`-.____`.___ \_____/___.-`___.-'=====       *
 *                        `=---='                        *
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      *
 *********__佛祖保佑__永无BUG__验收通过__钞票多多__*********
 *********************************************************/
package org.jbase.jbsc.commons.base.utils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jbase.jbsc.commons.core.query.PagerQuery;
import org.jbase.jbsc.commons.core.vo.PagerVo;

/**
 * Project: jbsc-commons <br/>
 * File: PagerUtil.java <br/>
 * Class: org.jbase.jbsc.commons.base.utils.PagerUtil <br/>
 * Description: <描述类的功能>. <br/>
 * Copyright: Copyright (c) 2011 <br/>
 * Company: https://gitee.com/liuzp315 <br/>
 * Makedate: 2020/9/22 上午9:35 <br/>
 *
 * @author popo
 * @version 1.0
 * @since 1.0
 */
public abstract class PagerUtil {

    public static <T> IPage<T> queryToPage(PagerQuery pq) {
        IPage<T> page = new Page<>();
        page.setSize(pq.getSize()).setCurrent(pq.getCurrent());
        return page;
    }

    public static <V, T> PagerVo<V> pageToVo(IPage pr, PagerVo<V> pv) {
        if (pv == null)
            pv = new PagerVo<V>();
        pv.setCurrent(pr.getCurrent()).setSize(pr.getSize()).setTotal(pr.getTotal()).setPages(pr.getPages()).setRecords(pr.getRecords());
        return pv;
    }
}
